﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace DotaHelp
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");


            routes.MapRoute(
                "Games",
                "Games/{action}",
                new { controller = "Games" }
            );

            routes.MapRoute(
                "Sitemap",
                "Sitemap",
                new { controller = "Home", action = "Sitemap" }
            );

            routes.MapRoute(
                "Sitemap.xml",
                "Sitemap.xml",
                new { controller = "Home", action = "Sitemap" }
            );

            routes.MapRoute(
                "robots.txt",
                "robots.txt",
                new { controller = "Home", action = "Robots" }
            );                       

			routes.MapRoute("Rules", "Rules", new { controller = "PurchasesRules", action = "List" });
			routes.MapRoute("HeroRule", "HeroRule/{id}", new { controller = "PurchasesRules", action = "List", id = UrlParameter.Optional, type = "HeroRule" });
			routes.MapRoute("ItemRule", "ItemRule/{id}", new { controller = "PurchasesRules", action = "List", id = UrlParameter.Optional, type = "ItemRule" });

            routes.MapRoute(
                "Rss",
                "Rss",
                new { controller = "Home", action = "Rss" }
                );

            routes.MapRoute(
                "Error",
                "Error/{error}",
                new { controller = "Home", action = "Error", error = "" }
                );

            routes.MapRoute(
                "EditGuide",
                "EditGuide/{id}/{password}",
                new { controller = "Guides", action = "Edit" }
                );

            routes.MapRoute(
                "EditTopic",
                "EditTopic/{id}/{password}",
                new { controller = "Forum", action = "Edit" }
                );

            routes.MapRoute(
               "ItemShops",
               "Item/Shops",
               new { controller = "Items", action = "Shops" }
               );

            routes.MapRoute(
               "ItemShopsDetail",
               "Item/Shops/Detail",
               new { controller = "Items", action = "ShopDetail" }
               );

            routes.MapRoute(
               "ItemEditShops",
               "Item/Shops/Edit",
               new { controller = "Items", action = "EditShops" }
               );
            routes.MapRoute(
               "ItemChangeShops",
               "Item/Shops/Change",
               new { controller = "Items", action = "ChangeShop" }
               );

            routes.MapRoute(
                "Item",
                "Item/{id}",
                new { controller = "Items", action = "Details"}
                );

            

            routes.MapRoute(
                "Command",
                "Command/{id}",
                new { controller = "Commands", action = "Details" }
                );

            routes.MapRoute(
                "Purchase",
                "Purchase/{id}",
                new { controller = "Purchases", action = "Details" }
                );

            routes.MapRoute(
                "Topic",
                "Topic/{id}",
                new { controller = "Forum", action = "Details" }
                );

            routes.MapRoute(
                "Upgrade",
                "Upgrade/{id}",
                new { controller = "Upgrades", action = "Details" }
                );

            routes.MapRoute(
                "Record",
                "Record/{id}",
                new { controller = "Records", action = "Details", id = "-1" }
                );

            routes.MapRoute(
                "ChooseHero",
                "ChooseHero/{title}/{nextActionName}/{nextControllerName}",
                new { controller = "Home", action = "ChooseHero"}
            );

            routes.MapRoute(
                "PurchaseIndex",
                "Purchase",
                new { controller = "Purchase", action = "List"}
            );

            routes.MapRoute(
                "Guide",
                "Guide/{id}",
                new { controller = "Guides", action = "Details", id = "-1" }
            );

            routes.MapRoute(
                "Hero",
                "Hero/{id}",
                new { controller = "Heroes", action = "Details", id = "-1" }
            );

            routes.MapRoute(
                "GuestBook",
                "GuestBook",
                new { controller = "Home", action = "GuestBook" }
                );

            routes.MapRoute(
                "Words",
                "Words",
                new { controller = "Dictionary", action = "List" }
                );

            
                routes.MapRoute(
                "Competition",
                "Competition",
                new { controller = "Competition", action = "List" }
                );

            routes.MapRoute(
                "Word",
                "Word/{group}",
                new { controller = "Dictionary", action = "List", group = UrlParameter.Optional }
                );

            routes.MapRoute(
                "Skill",
                "Skill/{id}",
                new { controller = "Skills", action = "Details", id = "" }
            );

           
            #region Устаревшие пути для поддержания внешних ссылок
            routes.MapRoute(
                "GuideOld",
                "gaid.php",
				new { controller = "Compatibility", action = "Guide", }
            );

            routes.MapRoute(
                "HeroOld",
                "gaidlist.php",
				new { controller = "Compatibility", action = "Hero", }
            );
            #endregion

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Heroes", action = "List", id = UrlParameter.Optional } // Parameter defaults
            );

            
        
        }
    }
}